//
//  ZTBSMViewController.m
//  CarTown
//
//  Created by xionghao on 15/8/29.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "ZTBSMViewController.h"
#import "HYSegmentedControl.h"
@interface ZTBSMViewController ()<HYSegmentedControlDelegate,UIScrollViewDelegate>
@property (nonatomic,strong) HYSegmentedControl *segemnt;
@property (nonatomic,strong) UIScrollView *scrollview;
@end

@implementation ZTBSMViewController

-(void)hySegmentedControlSelectAtIndex:(NSInteger)index{
    [self.scrollview setContentOffset:CGPointMake(XHScreenwidth*index, 0) animated:YES];
}

+(instancetype)Viewcontroller{
    ZTBSMViewController *vc=[[ZTBSMViewController alloc]init];
    vc.hidesBottomBarWhenPushed=YES;
    return vc;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"招投标须知";
    
    [self setupview];
    self.view.backgroundColor=[UIColor whiteColor];
    // Do any additional setup after loading the view from its nib.
}
-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

-(void)setupview{
    UIScrollView *scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, XHScreenwidth, XHScreenheight)];
    [self.view addSubview: scrollview];
    UIImageView *image1=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tbxz1"]];
    image1.frame=CGRectMake(0, 0, XHScreenwidth, 178.5);
    image1.contentMode=UIViewContentModeScaleAspectFill;
    [scrollview addSubview:image1];
    UIImageView *image2=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tbxz2"]];
    image2.frame=CGRectMake(0, 178.5, XHScreenwidth, 190.5);
    image2.contentMode=UIViewContentModeScaleAspectFill;
    [scrollview addSubview:image2];
    
    _segemnt=[[HYSegmentedControl alloc]initWithOriginY:369 Titles:@[@"招投标流程",@"招投标须知"] delegate:self];
    [scrollview addSubview:_segemnt];
    
    UIScrollView *scroll2=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 405, XHScreenwidth, 457.5)];
    [scrollview addSubview:scroll2];
    scroll2.contentSize=CGSizeMake(XHScreenwidth*2, 0);
    scroll2.pagingEnabled=YES;
    scroll2.showsHorizontalScrollIndicator=NO;
    scroll2.showsVerticalScrollIndicator=NO;
    scroll2.delegate=self;
    _scrollview=scroll2;
    UIImageView *image3=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"lz1"]];
    image3.frame=CGRectMake(0, 0, XHScreenwidth, 408);
    image3.contentMode=UIViewContentModeScaleAspectFill;
    [scroll2 addSubview:image3];
    UIImageView *image4=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"lc2"]];
    image4.frame=CGRectMake(XHScreenwidth, 0, XHScreenwidth, 457.5);
    image4.contentMode=UIViewContentModeScaleAspectFill;
    [scroll2 addSubview:image4];
    scrollview.contentSize=CGSizeMake(0, image1.height+image2.height+scroll2.height+30);
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    CGFloat x=scrollView.contentOffset.x;
    NSLog(@"%f",x);
    if (x/XHScreenwidth==1) {
        [self.segemnt changeSegmentedControlWithIndex:1];
        
    }else{
        [self.segemnt changeSegmentedControlWithIndex:0];
        
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
